package com.salt.core.log.sender;

import com.salt.core.log.prop.KafkaProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;

/**
 * @Description
 * @Author salt
 * @Date 2023/4/17
 * @Version 1.0.1
 */
@Slf4j
@Component
public class KafkaSender {

    @Autowired
    private KafkaTemplate<String, Object> kafkaTemplate;
    @Autowired
    private KafkaProperties kafkaProperties;

    public void send(Object o) {
        send(kafkaProperties.getTopic(), o);
    }

    public void send(String topic, Object o) {
        //log.info("topic: {}, message: {}", topic, operationLog);
        kafkaTemplate.send(topic, o);
    }
}
